/**
 * @author Rudy Kaplan Depena (The University of Texas at Austin)
 */
package com.utaustin.mirankerlab.ultrawrap.compiler.utilities;

import java.util.List;
import java.util.ArrayList;
import com.utaustin.mirankerlab.ultrawrap.compiler.expressionTree.sparql.EnumOperator;

/** Stack to keep track of scopes (i.e. Brackets) */
public class Stack {

	//instance variables
	private List<EnumOperator> stack;
	
	/**
	 * Default Constructor
	 */
	public Stack(){ stack = new ArrayList<EnumOperator>(); }
	
	/**
	 * Returns size of stack (i.e. - number of elements in stack)
	 * @return size
	 */
	public int size(){ return stack.size(); }
	
	/**
	 * Returns the top element of the stack
	 * @return EnumOperator
	 */
	public EnumOperator top(){
		int lastIdxOfStack = stack.size() - 1;
		return stack.get(lastIdxOfStack);
	}
	
	/**
	 * Remove top of the stack
	 * @return EnumOperator
	 */
	public EnumOperator pop(){
		int lastIdxOfStack = stack.size() - 1;
		return stack.remove(lastIdxOfStack);
	}
	
	/**
	 * Push element onto stack
	 * @param EnumOperator
	 */
	public void push(EnumOperator op){ stack.add(op); }
	
}
